package com.mzj.saas.mservice.smartlock.service.huixiangjia;

import com.alibaba.fastjson.JSONObject;
import com.mzj.saas.mservice.smartlock.vo.huixiangjia.HuiXiangJiaCallBack;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author xiaolong
 * @Date 2024/1/31
 **/
@Slf4j
@Service
public class SmartLockHxjCallBackService {

    @Autowired
    private SmartLockHxjEventHandleService smartLockHxjEventHandleService;

    public Map<String, Object> callBack(HuiXiangJiaCallBack huiXiangJiaCallBack) {
        log.info("慧享佳回调数据：{}", JSONObject.toJSONString(huiXiangJiaCallBack));
        switch (huiXiangJiaCallBack.getMethod()) {
            case "lockLogPush"://开门日志推送
                return smartLockHxjEventHandleService.lockOpenLog(huiXiangJiaCallBack.getData());
            case "hxjNBWakeUpPush"://门锁状态变化推送
                return smartLockHxjEventHandleService.lockStateLog(huiXiangJiaCallBack.getData());
        }
        return new HashMap<String, Object>() {
            {
                put("code", 200);
                put("message", "success");
            }
        };
    }
}
